'use strict'

define(['jquery', 'bootstrap', 'select2', 'shiftform', 'validate', 'validate.en', 
        'datetimepicker', 'koala-search', 'modalSearch'], function ($) {
  
  return {
    
    init: function () {
      this.initSearch();
      this.initExport();
    },

    initSearch: function() {
      
      $(document).on('shown.bs.modal', '#driver-search', function(e) {
        
        $('[data-target="#modal-search-vehicle"]').modalsearch({
          url: function(){
                var url = window.__CTX__.root + '/vehicles/query';
                return url + "?companyIds=";
             },
            tableColumns: ['驳运车代码', '驳运车名称'],
            tableValues: ['code', 'name'],
            displayValues: ['code', 'name'],
            values: ['id']
          });
        
        var options = {
          time: 1000,
          url: window.__CTX__.root + "/vehicles/query",
          queryName: "code",
          value: ["id"],
          display: ["code", "name"]
        }
        
        $('.vehicle-search').koalaSearch(options);
        
      });
      
    },
    
    initExport: function() {
      
      $(document).on('shown.bs.modal', '#driver-export', function(e) {
        $(e.currentTarget).find('form[data-validate="true"]').bt_validate()  //bind validate
      });
      
    }
    

  }
})